package com.ita.ios.jms.protocol;

import java.util.Date;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;


public class JmsProtocol {
	
	private static ObjectMapper mapper = new ObjectMapper();
	
	public static String serializeMerchantAudit(String mId) throws Exception{
		MerchantAuditProtocol map = new MerchantAuditProtocol(mId, new Date());
		return mapper.writeValueAsString(map);
	}
	
	public static String serializeDishAudit(String dId, String mId) throws JsonProcessingException{
		DishAuditProtocol dap = new DishAuditProtocol(dId, mId, new Date());
		return mapper.writeValueAsString(dap);
	}
	
	public static String serializeMerchantGrade(String mId) throws JsonProcessingException{
		LowAuditProtocol lap = new LowAuditProtocol(mId, new Date());
		return mapper.writeValueAsString(lap);
	}

	public static String serializeOrderComplaint(String oId, String mId, String cId) throws JsonProcessingException{
//		orderComplaint.setCreateTime(new Date());
		ComplaintAuditProtocol cap = new ComplaintAuditProtocol(oId, mId, cId, new Date());
		return mapper.writeValueAsString(cap);
	}

	public static Object deserializeObject(String merchantAuditStr, Class class_) throws Exception{
		Object merchantAudit = class_.newInstance();
		merchantAudit = mapper.readValue(merchantAuditStr, class_);
		return merchantAudit;
	}
}
